﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Trace.WebApi.Commands;

namespace Trace.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TracetController : ControllerBase
    {
        private readonly IMediator _mediator;

        public TracetController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 货主合同跟踪签收
        /// </summary>
        /// <param name="signHZTraceCommands"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> SignHZTracetAsync(SignHZTraceCommands signHZTraceCommands)
        {
            return Ok(await _mediator.Send(signHZTraceCommands));
        }

        /// <summary>
        /// 承运合同跟踪签收
        /// </summary>
        /// <param name="signCYTracetCommands"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> SignCYTracetAsync(SignCYTracetCommands signCYTracetCommands)
        {
            return Ok(await _mediator.Send(signCYTracetCommands));
        }

        /// <summary>
        /// 货主合同跟踪发货
        /// </summary>
        /// <param name="shipmentsHZTracetCommands"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ShipmentsHZTracetAsync(ShipmentsHZTracetCommands shipmentsHZTracetCommands)
        {
            return Ok(await _mediator.Send(shipmentsHZTracetCommands));
        }

        /// <summary>
        /// 承运合同跟踪发货
        /// </summary>
        /// <param name="shipmentsCYTracetCommands"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ShipmentsCYTracetAsync(ShipmentsCYTracetCommands shipmentsCYTracetCommands)
        {
            return Ok(await _mediator.Send(shipmentsCYTracetCommands));
        }

        /// <summary>
        /// 货主合同跟踪回单
        /// </summary>
        /// <param name="receiptHZTracetCommands"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ReceiptHZTracetAsync(ReceiptHZTracetCommands receiptHZTracetCommands)
        {
            return Ok(await _mediator.Send(receiptHZTracetCommands));
        }

        /// <summary>
        /// 货主合同跟踪回单
        /// </summary>
        /// <param name="receiptCYTracetCommands"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ReceiptCYTracetAsync(ReceiptCYTracetCommands receiptCYTracetCommands)
        {
            return Ok(await _mediator.Send(receiptCYTracetCommands));
        }

        /// <summary>
        /// 货运状态修改
        /// </summary>
        /// <param name="updTraceCommands"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> UpdTraceAsync(UpdTraceCommands updTraceCommands)
        {
            return Ok(await _mediator.Send(updTraceCommands));
        }
    }
}
